package com.wyq.miaosha.service;

import java.util.List;

import com.wyq.miaosha.dao.GoodsDao;
import com.wyq.miaosha.domain.MiaoshaGoods;
import com.wyq.miaosha.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class GoodsService {

	@Autowired
	GoodsDao goodsDao;

	public List<GoodsVo> listGoodsVo(){
		return goodsDao.listGoodsVo();
	}

	public GoodsVo getGoodsVoByGoodsId(long goodsId) {
		return goodsDao.getGoodsVoByGoodsId(goodsId);
	}

	@Transactional
	public int reduceStock(GoodsVo goods) {
		MiaoshaGoods g = new MiaoshaGoods();
		g.setGoodsId(goods.getId());
//		goodsDao.reduceStock(g);
		return goodsDao.reduceStock(g);
	}
}
